package com.knowledge.plus.设计模式.建造者模式;

import java.util.ArrayList;
import java.util.List;

/**
 * 建造者模式-建筑物类
 *
 * @author TPF
 * @since 2023/12/12
 */
public class Building {

    // 组装组件
    private List<String> buildingComponents = new ArrayList<>();

    // 修建地基
    public void setBasement(String basement) {
        buildingComponents.add(basement);
    }

    // 修建墙体
    public void setWall(String wall) {
        buildingComponents.add(wall);
    }

    // 修建屋顶
    public void setRoof(String roof) {
        buildingComponents.add(roof);
    }

    @Override
    public String toString() {
        String str = "";
        for (int i = buildingComponents.size() - 1; i >= 0; --i) {
            str += buildingComponents.get(i);
        }
        return str;
    }

}
